<?php
class Administrator_video_model extends CI_Model {

    function __construct()
    {
        parent::__construct();
    }	
	
	/*Type Management*/
	function type_management_add()
	{
		$video_type_name = $this->input->post('video_type_name');
		$video_type_alias = $this->input->post('video_type_alias');
		$is_tv_show = $this->input->post('is_tv_show');
		$datetime = date('Y-m-d H:i:s');
		
		//Insert video_type
		$data = array(
			'video_type_name' => $video_type_name,
			'video_type_alias' => $video_type_alias,
			'is_tv_show' => $is_tv_show,
			'update_by' => $this->session->userdata('username'),			
			'create_date' => $datetime,
			'update_date' => $datetime
		);
		$this->db->insert('video_type',$data);
	}
	
	function type_management_edit($video_type_id)
	{
		$video_type_name = $this->input->post('video_type_name');
		$video_type_alias = $this->input->post('video_type_alias');
		$is_tv_show = $this->input->post('is_tv_show');
		$datetime = date('Y-m-d H:i:s');
		
		//Update video_type
		$data = array(
			'video_type_name' => $video_type_name,
			'video_type_alias' => $video_type_alias,
			'is_tv_show' => $is_tv_show,
			'update_by' => $this->session->userdata('username'),			
			'update_date' => $datetime
		);
		$this->db->update('video_type',$data,array('video_type_id' => $video_type_id));				
	}	
	
	function type_management_delete()
	{
		$id = $this->input->post('id');
		foreach($id as $value):
			$tables = array('video_type');
			$this->db->where('video_type_id', $value);
			$this->db->delete($tables);			
		endforeach;			
	}		
		
	/*Content Management*/	
	function content_management_add()
	{
		$is_publish = $this->input->post('is_publish');
		$video_publish_date = $this->input->post('video_publish_date');
		$video_type_id = $this->input->post('video_type_id');
		$media_type_id = $this->input->post('media_type_id');
		$genre_id = $this->input->post('genre_id');
		$is_show_hilight_on_home = $this->input->post('is_show_hilight_on_home');
		$is_show_display_on_home = $this->input->post('is_show_display_on_home');
		$is_show_hilight_bhs = $this->input->post('is_show_hilight_bhs');
		$is_show_hilight_concert = $this->input->post('is_show_hilight_concert');
		$is_show_hilight_interview = $this->input->post('is_show_hilight_interview');
		$is_show_hilight_mv = $this->input->post('is_show_hilight_mv');
		$is_show_new_released = $this->input->post('is_show_new_released');
		$is_show_recommend = $this->input->post('is_show_recommend');
		$is_show_video_hit = $this->input->post('is_show_video_hit');
		$letters = $this->input->post('letters');
		$video_name = $this->input->post('video_name');
		$video_description = $this->input->post('video_description');
		$video_embed = $this->input->post('video_embed');
		$video_tag = $this->input->post('video_tag');
		$is_relate_song = $this->input->post('is_relate_song');
		$song_id = $this->input->post('song_id');
		$default_artist_id = $this->input->post('default_artist_id');
		$artist_id = $this->input->post('artist_id');
		$album_id = $this->input->post('album_id');
		$uploadify_store = explode(',',$this->input->post('uploadify_store'));
		$uploadify_store2 = explode(',',$this->input->post('uploadify_store2'));		
		$datetime = date('Y-m-d H:i:s');		
		
		//Insert video
		$data = array(
			'video_type_id' => $video_type_id,
			'video_publish_date' => convertDatetime($video_publish_date),
			'media_type_id' => $media_type_id,
			'genre_id' => $genre_id,
			'is_publish' => $is_publish,
			'is_show_hilight_on_home' => $is_show_hilight_on_home,
			'is_show_display_on_home' => $is_show_display_on_home,
			'is_show_hilight_bhs' => $is_show_hilight_bhs,
			'is_show_hilight_concert' => $is_show_hilight_concert,
			'is_show_hilight_interview' => $is_show_hilight_interview,
			'is_show_hilight_mv' => $is_show_hilight_mv,
			'is_show_new_released' => $is_show_new_released,
			'is_show_recommend' => $is_show_recommend,
			'is_show_video_hit' => $is_show_video_hit,
			'is_show_display_on_home' => $is_show_display_on_home,
			'is_relate_song' => $is_relate_song,
			'letters' => $letters,
			'update_by' => $this->session->userdata('username'),
			'create_date' => $datetime,
			'update_date' => $datetime
		);
		$this->db->insert('video',$data);
		$video_id = $this->db->insert_id();
		
		//Update You2Play Intrend
		if(!empty($is_show_intrend)) $this->db->update('video',array('is_show_intrend' => '0'),array('video_id !=' => $video_id));		
		
		//Insert video_info
		$data = array(
			'video_id' => $video_id,
			'video_name' => $video_name,
			'video_description' => $video_description,
			'is_youtube' => (preg_match('/youtube/',$video_embed) ? '1':'0'),			
			'video_embed' => $video_embed,
			'video_tag' => $video_tag
		);
		$this->db->insert('video_info',$data);	

		//Insert video_image
		$dataImage = array();
		if(!empty($uploadify_store[0])) foreach($uploadify_store as $key => $value):
			//Resize Image
			$data = imageResize(array(
				'id' => $video_id,
				'source_image' => $this->temp_folder.$value,
				'new_path' => $this->upload_folder.'video/images/',
				'dimension' => array(				
					array(
						'width' => 120,
						'height' => 120
					)					
				)
			));			
			
			//delete temp
			@unlink($this->temp_folder.$value);
			
			$dataImage = array(
				'video_thumb_name' => $data->file_name,
				'video_thumb_ext' => $data->file_ext
			);	
		endforeach;
		if(!empty($dataImage)) $this->db->update('video_info',$dataImage,array('video_id' => $video_id));
				
		//Insert video_file
		$dataFile = array();
		if(!empty($uploadify_store2[0])) foreach($uploadify_store2 as $key => $value):
			$dateY = date('Y',strtotime($datetime)).'/';
			$dateM = date('m',strtotime($datetime)).'/';
			$dateD = date('d',strtotime($datetime)).'/';
			$source_image = $this->temp_folder.$value;
			$path_info= pathinfo($source_image);
			$new_path = $this->upload_folder.'video/files/';
			@mkdir($new_path.$dateY);
			@mkdir($new_path.$dateY.$dateM);
			@mkdir($new_path.$dateY.$dateM.$dateD);
			$new_path = $new_path.$dateY.$dateM.$dateD;
			$file_name= md5($video_id.rand());
			$new_image= $new_path.$file_name.'.'.$path_info['extension'];		
			while(file_exists(realpath($new_image))):
				$file_name = md5($video_id.rand());
				$new_image = $new_path.$file_name.'.'.$path_info['extension'];
			endwhile;			
			@copy($source_image,$new_image); //Put File to original
			//delete temp
			@unlink($this->temp_folder.$value);
			
			$dataFile = array(
				'video_file_name' => $file_name,
				'video_file_ext' => $path_info['extension']
			);	
		endforeach;
		if(!empty($dataFile)) $this->db->update('video_info',$dataFile,array('video_id' => $video_id));		
		
		if($is_relate_song){
			//Insert video_song
			$dataSongID = array();
			if(!empty($song_id)) foreach($song_id as $key => $value):
				$dataSongID[] = array(
					'video_id' => $video_id,
					'song_id' => $value				
				);
			endforeach;
			if(!empty($dataSongID)) $this->db->insert_batch('video_song',$dataSongID);
		} else {
			//Insert video_artist
			$dataArtistID = array();
			if(!empty($artist_id)) foreach($artist_id as $key => $value):
				$dataArtistID[] = array(
					'video_id' => $video_id,
					'artist_id' => $value,
					'is_default' => (in_array($value,$default_artist_id) ? '1':'0')
				);
			endforeach;
			if(!empty($dataArtistID)) $this->db->insert_batch('video_artist',$dataArtistID);
			
			//Insert video_album
			$dataAlbumID = array();
			if(!empty($album_id)) foreach($album_id as $key => $value):
				$dataAlbumID[] = array(
					'video_id' => $video_id,
					'album_id' => $value		
				);
			endforeach;
			if(!empty($dataAlbumID)) $this->db->insert_batch('video_album',$dataAlbumID);		
		}	
		
		//Update Solr
		$this->load->library('solr');	
			
		$document = new Apache_Solr_Document();
		$document->id = 'video_'.$video_id;
		$document->video_name_s = $video_name;
		$document->video_image_name_s = '';
		$document->video_tag_s = $video_tag;
		$document->last_modified = date("Y-m-d\TH:i:s\Z",strtotime($datetime));
		if(!empty($video_publish_date)) $document->last_modified = date("Y-m-d\TH:i:s\Z",strtotime(convertDatetime($video_publish_date)));
		
		if($is_relate_song){ 
			$song_id_i_arr = array();
			$artist_id_i_arr = array();
			$album_id_i_arr = array();		
			$dataVideoSong = $this->db->select('song_id')->
			get_where('video_song',array('video_id' => $video_id))->
			result();
			foreach($dataVideoSong as $song):
				$song_id_i_arr[] = $song->song_id;
				$dataSongArtist = $this->db->select('artist_id')->
				get_where('song_artist',array('song_id' => $song->song_id,'is_default' => '1'),1)->
				row();
				$artist_id_i_arr[] = $dataSongArtist->artist_id;
				$dataSongAlbum = $this->db->select('album_id')
				->get_where('song_album',array('song_id' => $song->song_id,'is_default' => '1'),1)
				->row();
				$album_id_i_arr[] = $dataSongAlbum->album_id;			
			endforeach;
			$document->song_id_i_arr = $song_id_i_arr;
			$document->artist_id_i_arr = $artist_id_i_arr;
			$document->album_id_i_arr = $album_id_i_arr;				
		} else {
			$artist_id_i_arr = array();
			if(!empty($dataArtistID)) foreach($dataArtistID as $value):
				if($value['is_default'] == 1) $artist_id_i_arr[] = $value['artist_id'];	
			endforeach;
			$document->artist_id_i_arr = $artist_id_i_arr;	
			
			$album_id_i_arr = array();
			if(!empty($dataAlbumID)) foreach($dataAlbumID as $value):
				$album_id_i_arr[] = $value['album_id'];		
			endforeach;	
			$document->album_id_i_arr = $album_id_i_arr;			
		}
		if(!empty($dataImage)) $document->video_image_name_s = $dataImage['video_thumb_name'].'.'.$dataImage['video_thumb_ext'];
		
		if($this->solr->ping() && !empty($document)):
			$this->solr->addDocument($document);
			$this->solr->commit(); //commit to see the deletes and the document
			$this->solr->optimize(); //merges multiple segments into one
		endif;
		
		//Clear Memcache
		$this->memcache->delete('dataHomeVideoMV');
		$this->memcache->delete('dataHomeVideoInterview');
		$this->memcache->delete('dataHomeVideoConcert');
		$this->memcache->delete('dataHomeVideoNews');					
		$this->memcache->delete('dataHomeVideoTv');	
		$this->memcache->delete('dataVdoMv');				
		$this->memcache->delete('dataVdoConcert');				
		$this->memcache->delete('dataVdoView');				
		$this->memcache->delete('dataVdoBehind');				
		$this->memcache->delete('dataVdoTv');				
	}
	
	function content_management_edit($video_id)
	{
		$is_publish = $this->input->post('is_publish');
		$video_publish_date = $this->input->post('video_publish_date');
		$video_type_id = $this->input->post('video_type_id');
		$media_type_id = $this->input->post('media_type_id');
		$genre_id = $this->input->post('genre_id');
		$is_show_hilight_on_home = $this->input->post('is_show_hilight_on_home');
		$is_show_display_on_home = $this->input->post('is_show_display_on_home');
		$is_show_hilight_bhs = $this->input->post('is_show_hilight_bhs');
		$is_show_hilight_concert = $this->input->post('is_show_hilight_concert');
		$is_show_hilight_interview = $this->input->post('is_show_hilight_interview');
		$is_show_hilight_mv = $this->input->post('is_show_hilight_mv');
		$is_show_new_released = $this->input->post('is_show_new_released');
		$is_show_recommend = $this->input->post('is_show_recommend');
		$is_show_video_hit = $this->input->post('is_show_video_hit');
		$letters = $this->input->post('letters');
		$video_name = $this->input->post('video_name');
		$video_description = $this->input->post('video_description');
		$video_embed = $this->input->post('video_embed');
		$video_tag = $this->input->post('video_tag');
		$is_relate_song = $this->input->post('is_relate_song');
		$song_id = $this->input->post('song_id');
		$default_artist_id = $this->input->post('default_artist_id');
		$artist_id = $this->input->post('artist_id');
		$album_id = $this->input->post('album_id');
		$uploadify_store = explode(',',$this->input->post('uploadify_store'));
		$uploadify_store2 = explode(',',$this->input->post('uploadify_store2'));	
		$datetime = date('Y-m-d H:i:s');
		
		//Insert video
		$data = array(
			'video_type_id' => $video_type_id,
			'video_publish_date' => convertDatetime($video_publish_date),
			'media_type_id' => $media_type_id,
			'genre_id' => $genre_id,
			'is_publish' => $is_publish,
			'is_show_hilight_on_home' => $is_show_hilight_on_home,
			'is_show_display_on_home' => $is_show_display_on_home,
			'is_show_hilight_bhs' => $is_show_hilight_bhs,
			'is_show_hilight_concert' => $is_show_hilight_concert,
			'is_show_hilight_interview' => $is_show_hilight_interview,
			'is_show_hilight_mv' => $is_show_hilight_mv,
			'is_show_new_released' => $is_show_new_released,
			'is_show_recommend' => $is_show_recommend,
			'is_show_video_hit' => $is_show_video_hit,
			'is_show_display_on_home' => $is_show_display_on_home,
			'is_relate_song' => $is_relate_song,
			'letters' => $letters,
			'update_by' => $this->session->userdata('username'),
			'update_date' => $datetime
		);
		$this->db->update('video',$data,array('video_id' => $video_id));
		
		//Update You2Play Intrend
		if(!empty($is_show_intrend)) $this->db->update('video',array('is_show_intrend' => '0'),array('video_id !=' => $video_id));
				
		//Insert video_info
		$data = array(
			'video_name' => $video_name,
			'video_description' => $video_description,
			'is_youtube' => (preg_match('/youtube/',$video_embed) ? '1':'0'),			
			'video_embed' => $video_embed,
			'video_tag' => $video_tag
		);
		$this->db->update('video_info',$data,array('video_id' => $video_id));	

		//Insert video_image
		$dataImage = array();
		if(!empty($uploadify_store[0])) foreach($uploadify_store as $key => $value):
			//Resize Image
			$data = imageResize(array(
				'id' => $video_id,
				'source_image' => $this->temp_folder.$value,
				'new_path' => $this->upload_folder.'video/images/',
				'dimension' => array(					
					array(
						'width' => 120,
						'height' => 120
					)					
				)
			));			

			//delete temp
			@unlink($this->temp_folder.$value);
			$dataInfo = $this->db->get_where('video_info',array('video_id' => $video_id),1)->row();
			$map = directory_map($this->upload_folder.'video/images/', 1);
			foreach($map as $folder):
				@unlink($this->upload_folder.'video/images/'.$folder.'/'.$dataInfo->video_thumb_name.'.'.$dataInfo->video_thumb_ext);
			endforeach;
			
			$dataImage = array(
				'video_thumb_name' => $data->file_name,
				'video_thumb_ext' => $data->file_ext
			);	
		endforeach;
		if(!empty($dataImage)) $this->db->update('video_info',$dataImage,array('video_id' => $video_id));
				
		//Insert video_file
		$dataFile = array();
		if(!empty($uploadify_store2[0])) foreach($uploadify_store2 as $key => $value):
			$dataInfo = $this->db->select('t.*,j.create_date')
			->join('video as j','j.video_id=t.video_id','INNER')
			->get_where('video_info as t',array('t.video_id' => $video_id),1)->row();
					
			$dateY = date('Y',strtotime($dataInfo->create_date)).'/';
			$dateM = date('m',strtotime($dataInfo->create_date)).'/';
			$dateD = date('d',strtotime($dataInfo->create_date)).'/';
			$source_image = $this->temp_folder.$value;
			$path_info= pathinfo($source_image);
			$new_path = $this->upload_folder.'video/files/';
			@mkdir($new_path.$dateY);
			@mkdir($new_path.$dateY.$dateM);
			@mkdir($new_path.$dateY.$dateM.$dateD);
			$new_path = $new_path.$dateY.$dateM.$dateD;
			$file_name= md5($video_id.rand());
			$new_image= $new_path.$file_name.'.'.$path_info['extension'];		
			while(file_exists(realpath($new_image))):
				$file_name = md5($video_id.rand());
				$new_image = $new_path.$file_name.'.'.$path_info['extension'];
			endwhile;			
			@copy($source_image,$new_image); //Put File to original
			
			//delete temp		
			@unlink($this->upload_folder.'video/files/'.$dateY.$dateM.$dateD.$dataInfo->video_file_name.'.'.$dataInfo->video_file_ext);
			@unlink($this->temp_folder.$value);
			
			$dataFile = array(
				'video_file_name' => $file_name,
				'video_file_ext' => $path_info['extension']
			);	
		endforeach;
		if(!empty($dataFile)) $this->db->update('video_info',$dataFile,array('video_id' => $video_id));		
		
		if($is_relate_song){
			//Delete video_song
			$this->db->delete('video_song',array('video_id' => $video_id));	
			//Delete video_artist
			$this->db->delete('video_artist',array('video_id' => $video_id));					
			//Insert video_song
			$dataSongID = array();
			if(!empty($song_id)) foreach($song_id as $key => $value):
				$dataSongID[] = array(
					'video_id' => $video_id,
					'song_id' => $value				
				);
			endforeach;
			if(!empty($dataSongID)) $this->db->insert_batch('video_song',$dataSongID);
		} else {
			//Delete video_song
			$this->db->delete('video_song',array('video_id' => $video_id));			
			//Delete video_artist
			$this->db->delete('video_artist',array('video_id' => $video_id));				
			//Insert video_artist
			$dataArtistID = array();
			if(!empty($artist_id)) foreach($artist_id as $key => $value):
				$dataArtistID[] = array(
					'video_id' => $video_id,
					'artist_id' => $value,
					'is_default' => (in_array($value,$default_artist_id) ? '1':'0')
				);
			endforeach;
			if(!empty($dataArtistID)) $this->db->insert_batch('video_artist',$dataArtistID);

			//Delete video_album
			$this->db->delete('video_album',array('video_id' => $video_id));
			
			//Insert video_album
			$dataAlbumID = array();
			if(!empty($album_id)) foreach($album_id as $key => $value):
				$dataAlbumID[] = array(
					'video_id' => $video_id,
					'album_id' => $value		
				);
			endforeach;
			if(!empty($dataAlbumID)) $this->db->insert_batch('video_album',$dataAlbumID);
		}	
		
		//Update Solr
		$this->load->library('solr');	
			
		$document = new Apache_Solr_Document();
		$document->id = 'video_'.$video_id;
		$document->video_name_s = $video_name;
		$document->video_tag_s = $video_tag;
		$document->last_modified = date("Y-m-d\TH:i:s\Z",strtotime($datetime));
		if(!empty($video_publish_date)) $document->last_modified = date("Y-m-d\TH:i:s\Z",strtotime(convertDatetime($video_publish_date)));
		
		if($is_relate_song){ 
			$song_id_i_arr = array();
			$artist_id_i_arr = array();
			$album_id_i_arr = array();		
			$dataVideoSong = $this->db->select('song_id')->
			get_where('video_song',array('video_id' => $video_id))->
			result();
			foreach($dataVideoSong as $song):
				$song_id_i_arr[] = $song->song_id;
				$dataSongArtist = $this->db->select('artist_id')->
				get_where('song_artist',array('song_id' => $song->song_id,'is_default' => '1'),1)->
				row();
				$artist_id_i_arr[] = $dataSongArtist->artist_id;
				$dataSongAlbum = $this->db->select('album_id')
				->get_where('song_album',array('song_id' => $song->song_id,'is_default' => '1'),1)
				->row();
				$album_id_i_arr[] = $dataSongAlbum->album_id;			
			endforeach;
			$document->song_id_i_arr = $song_id_i_arr;
			$document->artist_id_i_arr = $artist_id_i_arr;
			$document->album_id_i_arr = $album_id_i_arr;			
		} else {
			$artist_id_i_arr = array();
			if(!empty($dataArtistID)) foreach($dataArtistID as $value):
				if($value['is_default'] == 1) $artist_id_i_arr[] = $value['artist_id'];	
			endforeach;
			$document->artist_id_i_arr = $artist_id_i_arr;	
			
			$album_id_i_arr = array();
			if(!empty($dataAlbumID)) foreach($dataAlbumID as $value):
				$album_id_i_arr[] = $value['album_id'];		
			endforeach;	
			$document->album_id_i_arr = $album_id_i_arr;			
		}
		
		$dataImage = $this->db->select('video_thumb_name,video_thumb_ext')->get_where('video_info',array('video_id' => $video_id),1)->row();
		if(!empty($dataImage->video_thumb_name)) $document->video_image_name_s = $dataImage->video_thumb_name.'.'.$dataImage->video_thumb_ext;

		if($this->solr->ping() && !empty($document)):
			$this->solr->addDocument($document);
			$this->solr->commit(); //commit to see the deletes and the document
			$this->solr->optimize(); //merges multiple segments into one
		endif;	
		
		//Clear Memcache
		$this->memcache->delete('dataHomeVideoMV');
		$this->memcache->delete('dataHomeVideoInterview');
		$this->memcache->delete('dataHomeVideoConcert');
		$this->memcache->delete('dataHomeVideoNews');					
		$this->memcache->delete('dataHomeVideoTv');	
		$this->memcache->delete('dataVdoMv');				
		$this->memcache->delete('dataVdoConcert');				
		$this->memcache->delete('dataVdoView');				
		$this->memcache->delete('dataVdoBehind');				
		$this->memcache->delete('dataVdoTv');						
	}
	
	function ajax_delete_media($video_id,$field = array())
	{
		$dataInfo = $this->db
		->join('video_info as j','j.video_id=t.video_id','INNER')
		->get_where('video as t',array('t.video_id' => $video_id),1)
		->row();
		$this->db->update('video_info',array(''.$field[0].'' => '',''.$field[1].'' => ''),array('video_id' => $video_id));
		//Delete File
		$dateY = date('Y',strtotime($dataInfo->create_date)).'/';
		$dateM = date('m',strtotime($dataInfo->create_date)).'/';
		$dateD = date('d',strtotime($dataInfo->create_date)).'/';
		@unlink($this->upload_folder.'video/files/'.$dateY.$dateM.$dateD.$dataInfo->{''.$field[0].''}.'.'.$dataInfo->{''.$field[1].''});	
		exit;
	}		
	
	function content_management_delete()
	{
		$id = $this->input->post('id');
		$map = directory_map($this->upload_folder.'video/images/', 1);
		$ids = array();
		foreach($id as $value):
			$ids[] = "video_".$value;
			$dataInfo = $this->db->select('t.*,j.create_date')
			->join('video as j','j.video_id=t.video_id','INNER')
			->get_where('video_info as t',array('t.video_id' => $value))->row();
			$tables = array('video','video_info','video_song','video_artist','video_album','video_click_stat');
			$this->db->where('video_id', $value);
			$this->db->delete($tables);
			//Delete All Image
			foreach($map as $folder):
				@unlink($this->upload_folder.'video/images/'.$folder.'/'.$dataInfo->video_thumb_name.'.'.$dataInfo->video_thumb_ext);
			endforeach;
			//Delete File
			$dateY = date('Y',strtotime($dataInfo->create_date)).'/';
			$dateM = date('m',strtotime($dataInfo->create_date)).'/';
			$dateD = date('d',strtotime($dataInfo->create_date)).'/';			
			@unlink($this->upload_folder.'video/files/'.$dateY.$dateM.$dateD.$dataInfo->video_file_name.'.'.$dataInfo->video_file_ext);
		endforeach;	
		
		//Update Solr
		$this->load->library('solr');	
		if($this->solr->ping() && !empty($ids)):
			$this->solr->deleteByMultipleIds($ids);
			$this->solr->commit(); //commit to see the deletes and the document
			$this->solr->optimize(); //merges multiple segments into one
		endif;	
		
		//Clear Memcache
		$this->memcache->delete('dataHomeVideoMV');
		$this->memcache->delete('dataHomeVideoInterview');
		$this->memcache->delete('dataHomeVideoConcert');
		$this->memcache->delete('dataHomeVideoNews');					
		$this->memcache->delete('dataHomeVideoTv');
		$this->memcache->delete('dataVdoMv');				
		$this->memcache->delete('dataVdoConcert');				
		$this->memcache->delete('dataVdoView');				
		$this->memcache->delete('dataVdoBehind');				
		$this->memcache->delete('dataVdoTv');						
	}
	
	/*Video Recommend*/
	function video_recommend()
	{
		$video_slot_1 = $this->input->post('video_id_1');
		$video_slot_2 = $this->input->post('video_id_2');
		$video_slot_3 = $this->input->post('video_id_3');
		$video_slot_4 = $this->input->post('video_id_4');
		$video_slot_5 = $this->input->post('video_id_5');
		$data = array($video_slot_1, $video_slot_2, $video_slot_3, $video_slot_4, $video_slot_5);
		
		//Update
		if(!empty($data)) $this->db->update('module_page',array('json' => json_encode($data)),array('page' => 'video_recommend'));
		
		//Clear Memcache
		$this->memcache->delete('dataModuleVideoRecommend');
	}
}

?>